<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="referrer" content="never" />
<title>演示页面</title>
<script>
if(top != self){  
	top.location.href = self.location.href;  
}
document.write("<script src='./js/jquery-3.6.0.min.js'><\/script>");
document.write("<script src='./js/JW.js?v="+Math.random()+"'><\/script>"); //全国经度数据,来源于寿星万年历
document.write("<script src='./js/infinity.js?v="+Math.random()+"'><\/script>"); //无限级选择

document.write("<script src='./js/paipan.js?v="+Math.random()+"'><\/script>");
<!-- document.write("<script src='./js/paipan.min.js?v="+Math.random()+"'><\/script>"); -->

document.write("<script src='./js/paipan.gx.js?v="+Math.random()+"'><\/script>"); //天干地支刑冲合害
</script> 
</head>
<body>

<div>
公历北京时间:
<br />
<select id="yy" onchange="chg()" style="width:60px;"></select>年
<select id="mm" onchange="chg()" style="width:50px;"></select>月
<select id="dd" onchange="chg()" style="width:50px;"></select>日
<select id="hh" onchange="chg()" style="width:50px;"></select>時
<select id="mt" onchange="chg()" style="width:50px;"></select>分
<select id="ss" onchange="chg()" style="width:50px;"></select>秒

<span id="city"></span>
</div>

<div>
<textarea id='text' style="width:1000px;height:2000px;"></textarea>
</div>

<script>
var ckey = new Array();
ckey[0] = '年柱';
ckey[1] = '月柱';
ckey[2] = '日柱';
ckey[3] = '时柱';
ckey[4] = '大运';
ckey[5] = '流年';
ckey[6] = '流月';
ckey[7] = '流日';
ckey[8] = '流时';

var tgdz = new Array();
tgdz[0] = '天干';
tgdz[1] = '地支';

function chg(){

	var id = inf.get();
	if((id == 0) || (JW[id] == undefined)){
		$('#text').val("请选择城市!");
		return false;
	}
	var txt = '';
	
	var d = new Date();
	var yy = d.getFullYear();
	var mm = d.getMonth() + 1;
	var dd = d.getDate();
	var hh = d.getHours();
	var mt = d.getMinutes();
	var ss = d.getSeconds();
	var now = p.Jdays(yy, mm, dd, 12, 0, 0); //今天的儒略日
	
	var fm = p.fatemaps(0, yy, mm, dd, hh, mt, ss); //不考虑真太阳时
	txt += "本机时间:"+yy+"年"+mm+"月"+dd+"日"+hh+"时"+mt+"分"+ss+"秒"+"\n";
	var y = fm.nl[0].toString().split("");
	var s = '';
	for(var i=0; i<y.length; i++){
		s += p.dxs[y[i]];
	}
	txt += "农历日期:"+s+"年"+(fm.nl[3]?'闰':'')+p.dxy[fm.nl[1]-1]+p.dxd[fm.nl[2]-1]+"\n";
	var [y, m, d] = p.Lunar2Solar(fm.nl[0] + 1, 1, 1, false); //农历年初一
	txt += "大年初一:"+y+"年"+m+"月"+d+"日\n";
	
	var jd = p.Jdays(y, m, d, 12, 0, 0) - 1; //年初一的儒略日减一为年三十或年廿九,不知道它闰不闰也不知道它大还是小,所以倒推
	 
	var [y, m, d] = p.Jtime(jd);
	txt += "大年三十:"+y+"年"+m+"月"+d+"日[倒计时:"+(jd - now)+"天]\n";
	
	var jq = p.GetAdjustedJQ(yy - 1, false);
	var days = now - Math.floor(jq[18] + 0.5); //距离冬至的天数
	if((days >= 0) && (days <= 81)){ //冬至
		txt += p.dxs[(parseInt(days / 9) + 1)] + "九第" + ((days % 9) + 1) + "天\n";
	}

	var jq = p.GetAdjustedJQ(yy, false);
	var [y, m, d] = p.Jtime(jq[6]); //夏至
	var gz = p.GetGZ(y, m, d, 12, 0, 0); //夏至那天的干支
	var days = (6 >= gz[0][2]) ? (6 - gz[0][2]) : (6 - gz[0][2] + 12); 
	var jd = jq[6] + days + 20; //夏至日干离第三个"庚"日的日数,计算初伏
	var [y, m, d] = p.Jtime(jd);
	txt += "初伏开始:"+y+"年"+m+"月"+d+"日\n";

	var jd = p.Jdays(yy, 6, 1, 12, 0, 0);
	var w = p.GetWeek(yy, 6, 1); //今年6月1日为星期几
	var days = (0 - w + 7); //离第一个周日还有多少天
	jd = jd + days + 2 * 7; //第三个周日
	var [y, m, d] = p.Jtime(jd);
	txt += "父亲节:"+y+"年"+m+"月"+d+"日\n";

	var jw = JW[id];
	var yy = parseInt($("#yy").val());
	var mm = parseInt($("#mm").val());
	var dd = parseInt($("#dd").val());
	var hh = parseInt($("#hh").val());
	var mt = parseInt($("#mt").val());
	var ss = parseInt($("#ss").val());
	
	$('#text').val('');
	if(p.ValidDate(yy, mm, dd) === false){
		$('#text').val("不存在此公历日期");
		return false;
	}
	txt += "\n";
	
	var J = jw[2]+jw[3]/60;
	var W = jw[4]+jw[5]/60;

	var fm = p.fatemaps(0, yy, mm, dd, hh, mt, ss, J, W); //此处演示真太阳时排盘

	txt += "公历北京时间为:"+yy+"年"+mm+"月"+dd+"日"+hh+"时"+mt+"分"+ss+"秒"+"\n";
	txt += "本地平太阳时为:"+fm['pty'][0]+"年"+fm['pty'][1]+"月"+fm['pty'][2]+"日"+fm['pty'][3]+"时"+fm['pty'][4]+"分"+fm['pty'][5]+"秒"+"\n";
	txt += "本地真太阳时为:"+fm['zty'][0]+"年"+fm['zty'][1]+"月"+fm['zty'][2]+"日"+fm['zty'][3]+"时"+fm['zty'][4]+"分"+fm['zty'][5]+"秒"+"\n\n";
	var jd = p.Jdays(yy, mm, dd, hh, mt, ss);
	txt += "对应的儒略日:"+jd+"\n\n";
	
	txt += "真太阳时八字为:"+p.ctg[fm.tg[0]]+p.cdz[fm.dz[0]]+p.ctg[fm.tg[1]]+p.cdz[fm.dz[1]]+p.ctg[fm.tg[2]]+p.cdz[fm.dz[2]]+p.ctg[fm.tg[3]]+p.cdz[fm.dz[3]]+"\n\n";
	
	txt += "该八字的刑冲合害关系:\n";
	var gxs = GetGX(fm['tg'], fm['dz']);
	for(var i in gxs){
		for(var j in gxs[i]){
			var gx = gxs[i][j];
			var a = [];
			for(var k in gx[0]){
				array_push(a, ckey[k] + tgdz[gx[1][0]]);
			}
			
			txt += implode('+', a) + ':' + gx[1][4] + "\n";
		}
	}

	txt += "\n该时刻出生的男士起运信息(各门派算法不同,此为其一):\n";
	txt += fm['qyy_desc'] + "(与十三行八字APP一致)\n";
	txt += fm['qyy_desc2'] + "\n";
	txt += "大运:\n";
	for(var x in fm['dy']){
		var a = fm['dy'][x];
		txt += a['zqage'] + "~" + a['zboz'] + "岁\t[" + a['syear'] + "-" + a['eyear'] + "年]\t" + a['zfma'] + "" + a['zfmb'] + "\t" + a['nzsc'] + "\n";
		
	}
	
	txt += "\n\n";
	txt += "[北京时间]:\n";
	var [utrise, utset, dt, trise, tset] = p.risenset(jd, J, W, 2);
	var t1 = (trise === false) ? ['-','-','-','-','-','-'] : p.Jtime(trise);
	var t2 = (tset === false) ? ['-','-','-','-','-','-'] : p.Jtime(tset);
	txt += "太阳升起:"+t1[3]+"时"+t1[4]+"分"+t1[5]+"秒\t"+"降落:"+t2[3]+"时"+t2[4]+"分"+t2[5]+"秒\n";
	
	var [utrise, utset] = p.risenset(jd, J, W, 3); //注意这里的dt来源
	var t1 = (utrise === false) ? ['-','-','-','-','-','-'] : p.Jtime(utrise - dt + (p.J - J) * 4 / 60 / 24);
	var t2 = (utset === false) ? ['-','-','-','-','-','-'] : p.Jtime(utset - dt + (p.J - J) * 4 / 60 / 24);
	txt += "海上微光:"+t1[3]+"时"+t1[4]+"分"+t1[5]+"秒\t"+"降落:"+t2[3]+"时"+t2[4]+"分"+t2[5]+"秒\n";
	
	var [utrise, utset] = p.risenset(jd, J, W, 1);
	var t1 = (utrise === false) ? ['-','-','-','-','-','-'] : p.Jtime(utrise - dt + (p.J - J) * 4 / 60 / 24);
	var t2 = (utset === false) ? ['-','-','-','-','-','-'] : p.Jtime(utset - dt + (p.J - J) * 4 / 60 / 24);
	txt += "月亮升起:"+t1[3]+"时"+t1[4]+"分"+t1[5]+"秒\t"+"降落:"+t2[3]+"时"+t2[4]+"分"+t2[5]+"秒\n\n";
	
	var [tg, dz] = p.GetGZ(yy, mm , dd, hh, mt, ss);
	txt += "对应的干支历:"+p.ctg[tg[0]]+p.cdz[dz[0]]+p.ctg[tg[1]]+p.cdz[dz[1]]+p.ctg[tg[2]]+p.cdz[dz[2]]+p.ctg[tg[3]]+p.cdz[dz[3]]+"\n";
	
	var d = p.gz2gl(p.GZ(tg[0], dz[0]), p.GZ(tg[1], dz[1]), p.GZ(tg[2], dz[2]), p.GZ(tg[3], dz[3]), 1949, 4); //从1949往后查4个甲子
	txt += "从1949年后4个甲子内四柱相同的有:\n"
	for(var i in d){
		var kk = d[i][0];
		var cc = d[i][1];
		txt += kk[0]+"年"+kk[1]+"月"+kk[2]+"日"+kk[3]+"时"+kk[4]+"分"+kk[5]+"秒~"+cc[0]+"年"+cc[1]+"月"+cc[2]+"日"+cc[3]+"时"+cc[4]+"分"+cc[5]+"秒\n";
	}
	txt += "\n";
	
	var d = p.Solar2Lunar(yy, mm, dd);
	var y = d[0].toString().split("");
	var s = '';
	for(var i=0; i<y.length; i++){
		s += p.dxs[y[i]];
	}
	txt += "对应的农历为:"+s+"年"+(d[3]?'闰':'')+p.dxy[d[1]-1]+p.dxd[d[2]-1]+"\n\n";
	
	var d = p.Lunar2Solar(d[0], 1, 1, false);
	var ob = d[3];
	txt += "农历"+s+"年"+(ob.leap ? ("闰"+ob.leap+"月") : "无闰月")+"\n\n";
	txt += "星期:"+p.wkd[p.GetWeek(yy, mm , dd)]+"\n\n";
	txt += "星座:"+p.cxz[p.GetXZ(yy, mm , dd, hh, mt, ss)]+"\n\n";
	
	txt += "此年("+yy+")公历:\n";
	for(var i=1; i<=12; i++){
		txt += ""+i+"月:"+p.GetSolarDays(yy, i)+"天;";
	}
	txt += "\n\n";
	
	txt += "此年("+s+")农历:\n";
	for(var i=1; i<=12; i++){
		txt += ""+p.dxy[i-1]+":"+ob['days'][i][0]+"天;";
		if(i == ob.leap){
			txt += "闰"+p.dxy[i-1]+":"+ob['days'][i][1]+"天;";
		}
	}
	txt += "\n\n";
	
	txt += "廿四节气:\n";
	var jq = p.GetAdjustedJQ(yy, false);
	for(var i in jq){
		var d = p.Jtime(jq[i]);

		txt += p.jq[parseInt(i)%24] + ":" +d[0]+"年"+d[1]+"月"+d[2]+"日"+d[3]+"时"+d[4]+"分"+d[5]+"秒"+"\n";
	}
	txt += "\n";
	
	$('#text').val(txt);
}
</script>
<script>
$(function(){
	for(var i=1949; i<=2049; i++){
		$('#yy').append("<option value='"+i+"'>"+i+"</option>");
	}
	for(var i=1; i<=12; i++){
		$('#mm').append("<option value='"+i+"'>"+i+"</option>");
	}
	for(var i=1; i<=31; i++){
		$('#dd').append("<option value='"+i+"'>"+i+"</option>");
	}
	for(var i=0; i<=23; i++){
		$('#hh').append("<option value='"+i+"'>"+i+"</option>");
	}
	for(var i=0; i<=59; i++){
		$('#mt').append("<option value='"+i+"'>"+i+"</option>");
	}
	for(var i=0; i<=59; i++){
		$('#ss').append("<option value='"+i+"'>"+i+"</option>");
	}
	
	var d = new Date();
	$("#yy").val(d.getFullYear());
	$("#mm").val(d.getMonth()+1);
	$("#dd").val(d.getDate());
	$("#hh").val(d.getHours());
	$("#mt").val(d.getMinutes());
	$("#ss").val(d.getSeconds());
	
	inf = new infinity();
	inf.init('city', JW, 2, chg);
		
	chg();
});
</script>
</body>
</html>